package main

import (
	"errors"
	"gitee.com/enjoy_5/cart-rpc/internal/api"
	"gitee.com/enjoy_5/cart-rpc/internal/model"
	grpc2 "gitee.com/xuxinzhi2206/corehub/grpc"
	"gitee.com/xuxinzhi2206/corehub/viper"
	"google.golang.org/grpc"
)

func main() {
	err := viper.GetViper("./config.yaml")
	if err != nil {
		panic(errors.New("viper read failed"))
	}

	err = model.Migrate()
	if err != nil {
		panic(errors.New("migrate failed"))
	}

	err = grpc2.RegisterRPC(func(s *grpc.Server) {
		api.Register(s)
	})
	if err != nil {
		panic(errors.New("register rpc failed"))
	}
}
